﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class GioiThieuDAO
    {
        private DataProvider provider;

        public GioiThieuDAO()
        {
            provider = new DataProvider();
        }

        public int ThemGioiThieu(GioiThieuDTO gioiThieu)
        {
            string sqlStatement = "INSERT INTO GioiThieu(MaSach, FileHinh) VALUES (" 
                + gioiThieu.MaSach + ", '" + gioiThieu.FileHinh + "')";

            return provider.ExecuteNonQuery(sqlStatement);
        }

        public int CapNhatGioiThieu(GioiThieuDTO gioiThieu)
        {
            string sqlStatement = "UPDATE GioiThieu SET MaSach=" + gioiThieu.MaSach + ", FileHinh='"
                + gioiThieu.FileHinh + "' WHERE MaGioiThieu=" + gioiThieu.MaGioiThieu;
            
            return provider.ExecuteNonQuery(sqlStatement);
        }

        public int XoaGioiThieu(GioiThieuDTO gioiThieu)
        {
            string sqlStatement = "DELETE FROM GioiThieu WHERE MaGioiThieu=" + gioiThieu.MaGioiThieu;

            return provider.ExecuteNonQuery(sqlStatement);
        }
    }
}
